<?php $this->load->view('register/_header') ?>
<?php $this->load->view('message') ?>

<script tyep="text/javascript">
  $(document).ready(function(){  
$('#school_id').selectpicker({});
$("#register_form").validate({
        rules:{
            school_id:
            {
                required:true,
                maxlength:45
            },
            major_id:
            {
                required:true,
                maxlength:45
            },
            username:
            {
                required:true,
                maxlength:45,
                remote: {
                    url: "<?php echo site_url('register/check_username_exist')?>",     //后台处理程序
                    type: "post",                //数据发送方式 
                    dataType: "json",          //接受数据格式  
                    data: {                     //要传递的数据
                            username: function() {
                            return $("#username").val();
                        }
                    }
                }
            },
            password_confirm:
            {
                equalTo:"#password"
            },
            teacher_number:
            {
                required:true,
                maxlength:45,
                remote: {
                    url: "<?php echo site_url('register/check_teacher_number_exist')?>",     //后台处理程序
                    type: "post",                //数据发送方式 
                    dataType: "json",          //接受数据格式  
                    data: {                     //要传递的数据
                        teacher_number: function() {
                            return $("#teacher_number").val();
                        },
                        school_id: function() {
                            return $("#school_id").val();
                        }
                    }
                }
            },
            name:
            {
                required:true,
                maxlength:45
            },
            password:
            {
                required:true,
                maxlength:45
            },
            password_confirm:
            {
                equalTo:"#password"
            }
        },
        messages:
        {
            username:
            {
                remote:"此用户名已存在"
            },
            teacher_number:
            {
                remote:"此工号已存在"
            },
            password_confirm:"两次输入的密码不一致"
            
        }
    });   
  });
// function find_majors_from_school(school_id_value)
//     {
//         myUrl="<?php echo site_url('register/find_relative_majors')?>/"+school_id_value;
//         $.ajax({
//             type:"post",
//             url:myUrl,
//             success:function(resp)
//             {
//                 $("#relative_majors").html(resp);
//             }
//         });
//     }
</script>

<div class="container">
    <div class="panel panel-primary">
        <div class="panel-heading">
            <h3 class="panel-title">用户注册</h3>
        </div>
        <div class="panel-body">
            <?php echo validation_errors(); ?>
            <form id="register_form" method="post" class="form-horizontal"  enctype="multipart/form-data" action="<?php echo site_url('register/teacher_register')?>" >
                <fieldset>
                            <div class="form-group">
                                <label for="select" class="col-lg-2 control-label">学校:</label>
                                <div class="col-lg-8">
                                    <select name="school_id" id="school_id" title="选择学校" class="selectpicker form-control" data-live-search="true"  data-style="btn-primary" onchange="find_majors_from_school(this.value);find_classes_from_school(this.value); " >
                                        <option value=0>
                                            --请选择学校--
                                        </option>
                                        <?php foreach ($schools as $item):?>
                                            <option value="<?=$item['id']?>">
                                                <?=$item['name']?>
                                            </option>
                                        <?php endforeach; ?>
                                    </select>
                                    <br>
                                </div>
                            </div>
                        <!-- <div class="col-lg-5">
                            <div class="form-group">
                                <label class="col-xs-4 control-label">专业:</label>
                                <div id='relative_majors' class="col-xs-8"></div>
                            </div>
                        </div> -->
                    <div class="form-group">
                        <label class="col-lg-2 control-label">用户名:</label>
                        <div class="col-lg-8">
                            <input class="form-control" id="username" name="username"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-2 control-label">姓名:</label>
                        <div class="col-lg-8">
                            <input class="form-control" id="name" name="name"/>                     
                        </div>
                    </div>
                    
                    <div class="form-group">
                        <label class="col-lg-2 control-label">密码:</label>
                        <div class="col-lg-8">
                            <input  type="password" class="form-control" id="password" name="password"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-lg-2 control-label">确认密码:</label>
                        <div class="col-lg-8">
                            <input  type="password" class="form-control" id="password_confirm" name="password_confirm"/>
                        </div>
                    </div>
                    
                    <div class="form-group">
                        <div class="col-lg-10 col-lg-offset-2">
                            <button type="submit" class="btn btn-primary">注册去登陆</button>
                        </div>
                    </div>
                </fieldset>
            </form>
        </div>
    </div>
</div>



    </body>
</html>
